﻿using System;
using System.Collections.Generic;
using ORM.Business.Models;

namespace ORM.Areas.Admin.Models
{
    /// <summary>
    /// Holds info of all main menu items of admin pages
    /// </summary>
    public static class AdminMenuCollection
    {
        public static IList<AdminMenuParent> Items { get; private set; }

        static AdminMenuCollection()
        {
            Items = new List<AdminMenuParent>();
            CreateStatMenus();
            CreateUserMenus();
            CreateContentsMenus();
            CreateCategoryMenus();             
            CreateApproveMenus();
            CreateSpamMenus();          
        }

        private static void CreateApproveMenus()
        {
            IList<AdminMenuChild> children = new List<AdminMenuChild>();
            Items.Add(new AdminMenuParent("Approval", "Approval", children));
            children.Add(new AdminMenuChild("ApproveGuides", "Approve Guides", "GuideUnapprovalIndex", "ManageApproval", KeyObject.Permission.ManageApproval));
            children.Add(new AdminMenuChild("ApproveAnswers", "Approve Answers", "QuestionApprovalIndex", "ManageApproval", KeyObject.Permission.ManageApproval));
        }

        private static void CreateCategoryMenus()
        {
            IList<AdminMenuChild> children = new List<AdminMenuChild>();
            Items.Add(new AdminMenuParent("Categories", "Categories", children));
            children.Add(new AdminMenuChild("ManageGuideType", "Manage Guide Types", "ManageGuideType", "ManageCategories", KeyObject.Permission.ManageCategories));
            children.Add(new AdminMenuChild("ManageDeviceCategories", "Manage Devices", "ManageDeviceCategories", "ManageCategories", KeyObject.Permission.ManageCategories));
            children.Add(new AdminMenuChild("ManageManufacturerCategories", "Manage Manufacturers", "ManageManufacturerCategories", "ManageCategories", KeyObject.Permission.ManageCategories));
            children.Add(new AdminMenuChild("ManageModelCategories", "Manage Models", "ManageModelCategories", "ManageCategories", KeyObject.Permission.ManageCategories));
        }

        private static void CreateContentsMenus()
        {
            IList<AdminMenuChild> children = new List<AdminMenuChild>();
            Items.Add(new AdminMenuParent("Contents", "Content", children));            
            children.Add(new AdminMenuChild("ManageGuides", "Manage Guides", "ManageGuides", "ManageContent", KeyObject.Permission.ManageContents));
            children.Add(new AdminMenuChild("ManageQuestions", "Manage Questions", "ManageQuestions", "ManageContent", KeyObject.Permission.ManageContents));
        }

        private static void CreateSpamMenus()
        {
            IList<AdminMenuChild> children = new List<AdminMenuChild>();
            Items.Add(new AdminMenuParent("Spam", "Spam", children));            
            children.Add(new AdminMenuChild("ManageReportedGuides", "Reported Guides", "ManageReportedGuide", "ManageSpam", KeyObject.Permission.ManageSpam));
            children.Add(new AdminMenuChild("ManageReportedComments", "Reported Comments", "ManageReportedComment", "ManageSpam", KeyObject.Permission.ManageSpam));
            children.Add(new AdminMenuChild("ManageReportedQuestions", "Reported Questions", "ManageReportedQuestion", "ManageSpam", KeyObject.Permission.ManageSpam));
        }

        private static void CreateUserMenus()
        {
            IList<AdminMenuChild> children = new List<AdminMenuChild>();
            Items.Add(new AdminMenuParent("Users", "Users", children));
            children.Add(new AdminMenuChild("ManageUsers", "Manage Users", "Index", "ManageUsers", KeyObject.Permission.ManageUsers));
            //children.Add(new AdminMenuChild("ManageRoles", "Manage Roles", "Index", "ManageRoles", KeyObject.Permission.ManageUsers));
        }

        private static void CreateStatMenus()
        {
            IList<AdminMenuChild> children = new List<AdminMenuChild>();
            Items.Add(new AdminMenuParent("Statistics", "Statistics", children));
            children.Add(new AdminMenuChild("ViewStatistics", "Website Statistics", "Index", "AdminStatistics", KeyObject.Permission.ManageUsers));
        }
    }
}
